<?php defined('SYSPATH') or die('No direct script access.');

/**
 * @file term.php
 * @brief 
 * @author Lionel Tsai
 * @version 1.0
 * @date 2012-02-17
 */

define('TERM_CUSGET', 0);
class Model_Term extends ORM {
	protected $_table_name = 'terms';
	protected $_primary_key = 'term_id';
	protected $_has_many = array(
		'types' => array('model' => 'type', 'foreign_key' => 'term_id')
	);


	function as_array($type = 0) {
	 $ret = array();
	 switch($type) {
	 case TERM_CUSGET:
		$ret = parent::as_array();
		//get pinyin
		$pinyin = new Tool_Pinyinparse();
		$ret['term_pinyin'] = $pinyin->Pinyin($ret['name'], 'UTF-8');
		break;
	 default:
	  $ret = parent::as_array();
	  break;	
		
	 }
	 return $ret;
	}


}
